#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<vector>
#include<string>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
using namespace std;
class Djset
{
public:
	vector<int> parent;
	int count;
	Djset(int n)
	{
		count = n;
		parent.resize(n);
		iota(parent.begin(), parent.end(), 0);
	}
	int find(int x)
	{
		if (x != parent[x])
			parent[x] = find(parent[x]);
		return parent[x];
	}
	void merge(int x, int y)
	{
		int fx = find(x), fy = find(y);
		if (fx == fy)
			return;
		parent[fy] = fx;
		count--;
	}
};
int minimumHammingDistance(vector<int>& source, vector<int>& target, vector<vector<int>>& allowedSwaps) {
	int n = source.size();
	Djset ds(n);
	for (auto& v : allowedSwaps)
	{
		ds.merge(v[0], v[1]);
	}
	unordered_map<int, unordered_multiset<int>> s, t;
	for (int i = 0; i < n; i++)
	{
		int fi = ds.find(i);
		s[fi].insert(source[i]);
		t[fi].insert(target[i]);
	}
	int ret = 0;
	for (int i = 0; i < n; i++)
	{
		if (s.find(i) == s.end())
			continue;
		for (auto& e : s[i])
		{
			if (t[i].find(e) == t[i].end())
				ret++;
			else
				t[i].erase(t[i].find(e));
		}
	}
	return ret;
}
int minSwapsCouples(vector<int>& row) {
	int n = row.size();
	int m = n / 2;
	Djset ds(m);
	for (int i = 0; i < m; i+=2)
	{
		int x = row[i] / 2;
		int y = row[i+1] / 2;
		ds.merge(x, y);
	}
	return m - ds.count;
}
int main()
{

	return 0;
}